import {Context} from 'koa'
import Tool from '../until/tool'

class MockController{
    // 获取传感器的数据
    async getData(ctx:Context) {
        let hum = Tool.random(39,40)
        let pre = Tool.random(68,110)
        let tem = Tool.random(31,40,true,2)
        let uvc = Tool.random(178,340)
        let inf = Tool.random(30,80)
        ctx.body = {
            code: 200,
            msg: "获取数据成功",
            data: {
                temperature:{temp:tem,temp_sta:2},
                pressure:{pre,"pre_sta":2},
                humidity:{hum,"hum_sta":0},
                ir: {"max":inf,"ir_sta":0},
                uvc: {"uv":uvc,"uvc_sta": Math.floor(Math.random()*3)}
             }
        }
    }
}


export default new MockController
